
import 'package:flutter/material.dart';
// import 'package:flutter_spinkit/flutter_spinkit.dart';

//class LoadingPage {
//  final BuildContext _context;
//
//  LoadingPage(this._context);
//
//  ///打开loading
//  void show({Function onClosed}) {
//    showDialog(
//      context: _context,
//      builder: (context) {
//        return SpinKitFadingCircle(color: Colors.white);
//      },
//    ).then((value) {
//      onClosed(value);
//    });
//  }
//
//  ///关闭loading
//  void close() {
//    Navigator.of(_context).pop();
//  }
//}
class LoadingDialog extends Dialog {
  String text;

  LoadingDialog({Key key, @required this.text}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return new Material( //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center( //保证控件居中效果
        child: new SizedBox(
          width: 120.0,
          height: 120.0,
          child: new Container(
            decoration: ShapeDecoration(
              color: Color(0xffffffff),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(
                  Radius.circular(8.0),
                ),
              ),
            ),
            child: new Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                new CircularProgressIndicator(),
                new Padding(
                  padding: const EdgeInsets.only(
                    top: 20.0,
                  ),
                  child: new Text(
                    text,
                    style: new TextStyle(fontSize: 12.0),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

